package com.example.mynews.Utils;

import android.util.Log;

import com.example.mynews.Pojo.Pojo_Msg;

import org.greenrobot.eventbus.EventBus;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

public class Ok_Utils {
    public static void ok_get(String url, final Integer tag)
    {
        OkHttpClient client=new OkHttpClient();
        Request request=new Request.Builder()
                .get()
                .url("http://192.168.1.109:8080/web_home"+url)
                .build();
        client.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                Log.d("xx","获取失败");
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                EventBus.getDefault().post(new Pojo_Msg(response.body().string(),tag));
            }
        });
    }
}
